package com.example.composestudy

import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController
import com.example.composestudy.part4.ConstraintLayoutTest
import com.example.composestudy.part6.*
import com.example.composestudy.part7.*
import com.example.composestudy.repository.Study

object StudyRouterConfig {
    const val Home = "home"

    const val Part4 = "part4"
    const val Part4_ConstraintLayout = "$Part4/ConstraintLayout"

    const val PART6 = "part6"
    const val PART6_HOME = "$PART6/home"
    const val PART6_POINT = "$PART6/point"
    const val PART6_LINE = "$PART6/line"
    const val PART6_RECT = "$PART6/rect"
    const val PART6_RoundRect = "$PART6/roundRect"
    const val PART6_Circle = "$PART6/circle"
    const val PART6_Oval = "$PART6/oval"
    const val PART6_Arc = "$PART6/arc"
    const val PART6_Image = "$PART6/image"
    const val PART6_Path = "$PART6/path"
    const val PART6_BlendMode = "$PART6/blendMode"
    const val StampedPathEffectSample = "$PART6/StampedPathEffectSample"

    const val Part7 = "part7"
    const val Part7_HOME = "$Part7/home"
    const val Part7_Easy1 = "$Part7/easy1"
    const val Part7_Easy2 = "$Part7/easy2"
    const val Part7_Easy3 = "$Part7/easy3"
    const val Part7_AnimateAsState = "$Part7/animateAsState"
    const val Part7_Animatable = "$Part7/animatable"

}

@Composable
fun StudyPage() {
    val navController = rememberNavController()
    NavHost(
        navController = navController,
        // startDestination = StudyRouterConfig.Home
        startDestination = StudyRouterConfig.Part4
    ) {
        composable(StudyRouterConfig.Home) {
            StudyPageList(
                navController,
                "Android全新UI编程",
                list = Study.list
            )
        }
        navigation(
            startDestination = StudyRouterConfig.PART6_HOME,
            route = StudyRouterConfig.PART6
        ) {
            composable(StudyRouterConfig.PART6_HOME) {
                StudyPageList(
                    navController,
                    title = "尝试Compose的自定义View",
                    list = Study.list_part6
                )
            }
            composable(StudyRouterConfig.PART6_POINT) { DrawPoint() }
            composable(StudyRouterConfig.PART6_LINE) { DrawLine() }
            composable(StudyRouterConfig.PART6_RECT) { DrawRect() }
            composable(StudyRouterConfig.PART6_RoundRect) { DrawRoundRect() }
            composable(StudyRouterConfig.PART6_Circle) { DrawCircle() }
            composable(StudyRouterConfig.PART6_Oval) { DrawOval() }
            composable(StudyRouterConfig.PART6_Arc) { DrawArc() }
            composable(StudyRouterConfig.PART6_Image) { DrawImage() }
            composable(StudyRouterConfig.PART6_Path) { DrawPath() }
            composable(StudyRouterConfig.PART6_BlendMode) { BlendModeTest() }
            composable(StudyRouterConfig.StampedPathEffectSample) { StampedPathEffectSample() }
        }
        navigation(
            startDestination = StudyRouterConfig.Part7_HOME,
            route = StudyRouterConfig.Part7
        ) {
            composable(StudyRouterConfig.Part7_HOME) {
                StudyPageList(
                    navController,
                    title = "动画的点点滴滴",
                    list = Study.listPart7
                )
            }
            composable(StudyRouterConfig.Part7_Easy1) { EasyAnimation() }
            composable(StudyRouterConfig.Part7_Easy2) { EasyAnimation2() }
            composable(StudyRouterConfig.Part7_Easy3) {
                Text(/*TODO*/"todo...")
            }
            composable(StudyRouterConfig.Part7_AnimateAsState) { AnimateAsSateTest() }
            composable(StudyRouterConfig.Part7_Animatable) { AnimatableTest() }
        }

        navigation(
            startDestination = StudyRouterConfig.Part4_ConstraintLayout,
            route = StudyRouterConfig.Part4
        ) {
            composable(StudyRouterConfig.Part4_ConstraintLayout) {
                ConstraintLayoutTest()
            }
        }
    }
}